///*
// * To change this template, choose Tools | Templates
// * and open the template in the editor.
// */
//package notificationcenter.ejb;
//
//import entities.Candidate;
//import entities.Company;
//import entities.Notification;
//import entities.User;
//import java.io.IOException;
//import java.io.Serializable;
//import java.net.URISyntaxException;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Properties;
//import javax.enterprise.event.Observes;
//import javax.faces.bean.ApplicationScoped;
//import javax.inject.Inject;
//import javax.inject.Named;
//import mail.EmailEJB;
//import mail.EmailTemplateHelper;
//import mail.datamodel.IdDataSource;
//import qualifiers.NotificationEmail;
//import util.EncryptTool;
//import util.MessagesHelper;
//
///**
// *
// * @author Alvaro
// */
//@Named
//@ApplicationScoped
//public class NotificationEmailsEjb implements Serializable{
//    @Inject
//    EmailEJB emailEJB;
//    
//    public void onNewNotification(@Observes @NotificationEmail Notification notification) throws IOException, URISyntaxException{
//        String subject="";
//        String html="";
//        //profile adquited
//        if(notification.getNotificationType().getIdNotificationType()==1){
//            subject="TheRecruitery. "+getSubjectAdquiredProfile(notification.getUserSender().getCompany(),notification.getUser());
//            html=EmailTemplateHelper.getHtmlHeader()+EmailTemplateHelper.getHtmlDivText(getSubjectAdquiredProfile(notification.getUserSender().getCompany(),notification.getUser())+".")+EmailTemplateHelper.getHtmlDivText(MessagesHelper.getMessage("AdquiredProfileText", notification.getUser()))+EmailTemplateHelper.getHtmlDivText(MessagesHelper.getMessage("VisitedAdquiredProfileText2", notification.getUser())+EmailTemplateHelper.getHtmlDivText(EmailTemplateHelper.getSocialNetworkFooter()));
//        }
//        //petición de video
//        else if(notification.getNotificationType().getIdNotificationType()==2){
//            subject="TheRecruitery. "+getSubjectRequestedvideo(notification.getUserSender().getCompany(),notification.getUser());
//            html=EmailTemplateHelper.getHtmlHeader()+EmailTemplateHelper.getHtmlDivText(getSubjectRequestedvideo(notification.getUserSender().getCompany(),notification.getUser())+".")+EmailTemplateHelper.getHtmlDivText(MessagesHelper.getMessage("RequestVideoText", notification.getUser()))+EmailTemplateHelper.getHtmlDivText(MessagesHelper.getMessage("RequestVideoText2", notification.getUser())+EmailTemplateHelper.getHtmlDivText(EmailTemplateHelper.getSocialNetworkFooter()));
//        }
//        //perfil visitado 
//        else if(notification.getNotificationType().getIdNotificationType()==3){
//            subject="TheRecruitery. "+getSubjectVisitedProfile(notification.getUserSender().getCompany(),notification.getUser());
//            html=EmailTemplateHelper.getHtmlHeader()+EmailTemplateHelper.getHtmlDivText(getSubjectVisitedProfile(notification.getUserSender().getCompany(),notification.getUser())+".")+EmailTemplateHelper.getHtmlDivText(MessagesHelper.getMessage("VisitedProfileText", notification.getUser()))+EmailTemplateHelper.getHtmlDivText(MessagesHelper.getMessage("VisitedAdquiredProfileText2", notification.getUser())+EmailTemplateHelper.getHtmlDivText(EmailTemplateHelper.getSocialNetworkFooter()));
//        }
//        //perfil reportado
//        else if(notification.getNotificationType().getIdNotificationType()==4){
//            subject="TheRecruitery. "+MessagesHelper.getMessage("ReportedUserSubject",notification.getUser());
//            html=EmailTemplateHelper.getHtmlHeader()+EmailTemplateHelper.getHtmlDivText(MessagesHelper.getMessage("ReportedProfile", notification.getUser()))+EmailTemplateHelper.getHtmlDivText(MessagesHelper.getMessage("ReportedProfile1", notification.getUser()))+EmailTemplateHelper.getHtmlDivText(EmailTemplateHelper.getSocialNetworkFooter());
//        }
//        //nueva búsqueda publica
//        else if(notification.getNotificationType().getIdNotificationType()==5){
//            subject="TheRecruitery. "+getSubjectNewSearchEmail(notification.getUserSender().getCompany(), notification.getUser().getCandidate());
//            html=EmailTemplateHelper.getHtmlHeader()+EmailTemplateHelper.getHtmlDivText(getSubjectNewSearchEmail(notification.getUserSender().getCompany(), notification.getUser().getCandidate())+".")+htmlPublicNewSearchEmail(notification.getUserSender().getCompany(),notification.getUser().getCandidate());
//        }
//        //nueva búsqueda privada
//        else if(notification.getNotificationType().getIdNotificationType()==6){
//            subject="TheRecruitery. "+getSubjectNewSearchEmail(notification.getUserSender().getCompany(), notification.getUser().getCandidate());
//            html=EmailTemplateHelper.getHtmlHeader()+EmailTemplateHelper.getHtmlDivText(getSubjectNewSearchEmail(notification.getUserSender().getCompany(), notification.getUser().getCandidate())+".")+htmlPrivateNewSearchEmail(notification.getUserSender().getCompany(),notification.getUser().getCandidate());
//        }
//        //si es búsqueda privada 
//        if(notification.getNotificationType().getIdNotificationType()!=5){
//            List<IdDataSource> dataSources=new ArrayList<IdDataSource>();
//            dataSources.add(new IdDataSource(EmailTemplateHelper.getFileDataSourceFromURL(Thread.currentThread().getContextClassLoader().getResource("emailLogo.png")), EmailTemplateHelper.logoId));
//            emailEJB.sendHtmlMail(notification.getUser().getEmail(), subject, html, dataSources);
//        }
//    }
//     
//     public String getSubjectVisitedProfile(Company company,User user) throws IOException{
//         StringBuilder menssageNotificacion= new StringBuilder();
//        if(company.getCompanyConfiguration().getShowName()){
//            menssageNotificacion.append(company.getName());
//        }
//        else{
//            menssageNotificacion.append(MessagesHelper.getMessage("NoNameCompany",user));
//        }
//        menssageNotificacion.append(" ");
//        menssageNotificacion.append(MessagesHelper.getMessage("ProfileVisited",user));
//        return menssageNotificacion.toString();
//                
//     }
//     
//     public String getSubjectAdquiredProfile(Company company,User user) throws IOException{
//         StringBuilder menssageNotificacion= new StringBuilder();
//        if(company.getCompanyConfiguration().getShowName()){
//            menssageNotificacion.append(company.getName());
//        }
//        else{
//            menssageNotificacion.append(MessagesHelper.getMessage("NoNameCompany",user));
//        }
//        menssageNotificacion.append(" ");
//        menssageNotificacion.append(MessagesHelper.getMessage("ProfileSelected",user));
//        return menssageNotificacion.toString();
//                
//     }
//     
//     public String getSubjectRequestedvideo(Company company,User user) throws IOException{
//         StringBuilder menssageNotificacion= new StringBuilder();
//        if(company.getCompanyConfiguration().getShowName()){
//            menssageNotificacion.append(company.getName());
//        }
//        else{
//            menssageNotificacion.append(MessagesHelper.getMessage("NoNameCompany",user));
//        }
//        menssageNotificacion.append(" ");
//        menssageNotificacion.append(MessagesHelper.getMessage("RequiredYouAVideo",user));
//        return menssageNotificacion.toString();
//                
//     }
//     
//     public String getSubjectNewSearchEmail(Company company,Candidate candidate) throws IOException{
//        Properties properties= MessagesHelper.getPropertyFromCandidate(candidate);
//
//        StringBuilder mensajeNotificacion=new StringBuilder();
//
//        mensajeNotificacion.append(properties.getProperty("Congratulations"));
//        mensajeNotificacion.append(" ");
//        if(company.getCompanyConfiguration().getShowName()){
//            mensajeNotificacion.append(company.getName());
//        }
//        else{
//            mensajeNotificacion.append(properties.getProperty("NoNameCompany"));
//        }
//        mensajeNotificacion.append(" ");
//        mensajeNotificacion.append(properties.getProperty("PreselectecNewSearch"));
//        return mensajeNotificacion.toString();
//     }
//    
//     public String htmlPublicNewSearchEmail(Company company,Candidate candidate) throws IOException{
//         Properties properties= MessagesHelper.getPropertyFromCandidate(candidate);
//         String companyName;
//         if(company.getCompanyConfiguration().getShowName()){
//            companyName=" "+company.getName()+" ";
//         }
//         else{
//             companyName=" "+properties.getProperty("TheCompany")+" ";
//         }
//         StringBuilder body=new StringBuilder();
//         body.append(EmailTemplateHelper.getHtmlDivText(properties.getProperty("PreselectecNewSearch1")+companyName+properties.getProperty("PreselectecNewSearch2")));
//         body.append(EmailTemplateHelper.getHtmlDivText(properties.getProperty("PreselectecNewSearch3")));
//         body.append(EmailTemplateHelper.getHtmlDivText(properties.getProperty("PreselectecNewSearch4")));
//         body.append(EmailTemplateHelper.getHtmlDivText(EmailTemplateHelper.getSocialNetworkFooter()));
//         return body.toString();
//     }
//     
//     public String htmlPrivateNewSearchEmail(Company company,Candidate candidate) throws IOException{
//         Properties properties= MessagesHelper.getPropertyFromCandidate(candidate);
//         StringBuilder body=new StringBuilder();
//         body.append(EmailTemplateHelper.getHtmlDivText(properties.getProperty("PreselectedNewSearch5")));
//         body.append(EmailTemplateHelper.getHtmlDivText(properties.getProperty("PreselectedNewSearch6")));
//         body.append(EmailTemplateHelper.getHtmlDivText(properties.getProperty("PreselectecNewSearch3")));
//         body.append(EmailTemplateHelper.getHtmlDivText(properties.getProperty("PreselectecNewSearch4")));
//         body.append(EmailTemplateHelper.getHtmlDivText(EmailTemplateHelper.getSocialNetworkFooter()));
//         return body.toString();
//     }
//     public String getURLNewSearch(Candidate candidate) throws Exception{
//         EncryptTool encrypTool= new EncryptTool();
//         String candidateId=encrypTool.encrypt(candidate.getIdCandidate().toString());
//         String url="http://TheRecruitery.com/xxxxxxx="+candidateId;
//         return url;
//     }
//
//}
